# -*- coding: utf-8 -*-
# time: 2025/5/15 15:26
# file: ch04_sdk_图片.py
# author: hanson
import os
from dashscope import MultiModalConversation, Application


def recognize_image_url(image_url, app_id):
    """识别网络图片"""
    response = Application.call(
        app_id=app_id,
        inputs={
            "image": image_url  # 直接传入URL
        }
    )

    if response.status_code == 200:
        print("Top1结果:", response.output['results'][0]['label'])
    else:
        print(f"识别失败: {response.message}")


# 使用示例
recognize_image_url(
    "https://ss-mpvolc.meipian.me/users/14289965/3407c1d6722d4057b3ddecda262cb425soi__jpeg.heic~tplv-s1ctq42ewb-s2-cC-q:750:0:0:0:q80.webp",
    "sk-62fb03f9198f4720bb359c873757fafc"
)